home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / patches / pgs3f.lha / 3.0fUpdate / Macros.LHA / MailMerge.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-04  |  3KB  |  107 lines

  1. /* $VER: PlaceGraphicAt.rexx 1.0 (04.02.95)
  2.    Copyright 1995 Soft-Logik Publishing Corporation
  3.    May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. TRACE OFF
  7.  
  8. /* Make sure rexx support is opened */
  9. IF ~SHOW('L','rexxsupport.library') THEN
  10.    CALL ADDLIB('rexxsupport.library',0,-30)
  11.  
  12. ADDRESS 'PAGESTREAM'
  13.  
  14. /* OPEN THE DATA FILE */
  15. getfile title "'Select the ASCII data file'" LOAD POSBUTTON "Ok" NEGBUTTON "Cancel"
  16. if rc~=0 then signal cleanup
  17. dfile=result
  18. call open(.ifile, dfile, 'R')
  19.  
  20. /* READ AND PARSE THE HEADER */
  21. dheader=readln(.ifile)
  22. fcount=1
  23. do forever
  24.     tpos=pos(d2c(9),dheader)
  25.     if tpos=0 then field.fcount=dheader
  26.         else field.fcount=left(dheader,tpos-1)
  27.     if tpos=0 then break
  28.     dheader=right(dheader,length(dheader)-tpos)
  29.     fcount=fcount+1
  30. end
  31.  
  32. /* SEE IF THE VARIABLES ALREADY EXIST */
  33. "setvariablevalue <nul>" variable field.1
  34. if rc~=0 then call createvar()
  35.  
  36. /* MAIL MERGE */
  37. /* ASK USER IF OK TO PRINT */
  38. allocarexxrequester '"Mail Merge"' 364 63
  39.     handle.req=result
  40. addarexxgadget handle.req EXIT 12 46 70 label "_Print"
  41.     handle.req.ok=result
  42. addarexxgadget handle.req EXIT 282 46 70 label "_Cancel"
  43.     handle.req.cancel=result
  44. addarexxgadget handle.req TEXT 8 10 356 border none string "'Is everything ready for printing? Click on'"
  45. addarexxgadget handle.req TEXT 8 22 356 border none string "'Print to start printing, or Cancel to exit.'"
  46. doarexxrequester handle.req
  47.     action=result
  48. freearexxrequester handle.req
  49. if action=handle.req.cancel then signal cleanup
  50.  
  51. do forever
  52.     /* READ THE RECORD */
  53.     dline=readln(.ifile)
  54.     if dline="" then break
  55.  
  56.     /* PARSE THE RECORD */
  57.     do i=1 to fcount
  58.         tpos=pos(d2c(9),dline)
  59.         if tpos=0 then line.i=dline
  60.             else line.i=left(dline,tpos-1)
  61.         line.i=d2c(39)||line.i||d2c(39)
  62.         dline=right(dline,length(dline)-tpos)
  63.         if tpos=0 then break
  64.     end i
  65.  
  66.     /* UPDATE PGS3 VARIABLES */
  67.     do i=1 to fcount
  68.         "setvariablevalue "line.i variable field.i
  69.     end i
  70.  
  71.     'refreshwindow'
  72. /*  'printdocument copies 1 page 1 sides both scale actual output grayscale printermarks off mirror off negative off'*/
  73. end
  74.  
  75. /* RESET VARIABLE NAMES */
  76. do i=1 to fcount
  77.     "setvariablevalue <"field.i">" variable field.i
  78. end i
  79. 'refreshwindow'
  80.  
  81. call cleanup()
  82. EXIT
  83.  
  84. CREATEVAR:
  85.     do i=1 to fcount
  86.         'newvariable 'field.i' «'field.i'»'
  87.     end i
  88.  
  89.     /* INFORM USER THAT VARS ARE CREATED */
  90.     allocarexxrequester '"Mail Merge"' 364 105
  91.         handle.req=result
  92.     addarexxgadget handle.req EXIT 147 88 70 label "_Ok"
  93.         handle.req.ok=result
  94.     addarexxgadget handle.req TEXT 8 10 356 border none string "'The mail merge variables have been created.'"
  95.     addarexxgadget handle.req TEXT 8 22 356 border none string "'Use the Type/Insert Variable » User String'"
  96.     addarexxgadget handle.req TEXT 8 34 356 border none string "'command to insert them into your document.'"
  97.     addarexxgadget handle.req TEXT 8 46 356 border none string "'When you are done, save it and then choose'"
  98.     addarexxgadget handle.req TEXT 8 58 356 border none string "'this macro again to print it.'"
  99.     doarexxrequester handle.req
  100.     freearexxrequester handle.req
  101.     signal cleanup
  102. RETURN
  103.  
  104. CLEANUP:
  105. call close(.ifile)
  106. EXIT
  107.